package com.android.youwenchuang.ui.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.android.youwenchuang.R;
import com.android.youwenchuang.bean.CarBean;
import com.android.youwenchuang.bean.Goods;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

public class CarAdapter extends BaseQuickAdapter<CarBean, BaseViewHolder> {
    public CarAdapter() {
        super(R.layout.item_car);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, CarBean item) {
        Goods goods = item.getGoods();
        if (goods != null) {
            baseViewHolder.setText(R.id.tv_name, goods.getName());
            baseViewHolder.setText(R.id.tv_price, "¥" + goods.getPrice());
            ImageView ivImage = baseViewHolder.getView(R.id.iv_image);
            Glide.with(getContext())
                    .load(goods.getPics())
                    .into(ivImage);
        }
        baseViewHolder.setText(R.id.tv_number, "数量：" + item.getCar().getNumber());
    }
}
